#include <stdio.h>
#include <opencv2/opencv.hpp>
#include <fstream>
#include <iostream>
#include <armadillo>
#include <iomanip>
//#include "H5Cpp.h"


//using namespace cv;
using namespace std;
using namespace arma;


#include "clustering_def.hpp"
#include "clustering_impl.hpp"


//Change CmakeList - see at the bottom ;)

int 
main(int argc, char** argv)
{
  
  mat X;
  //X.load("two_circles.dat");
  X.load("X.dat");
  
  cout << "Calculating Exponential Kernel " << endl;  
  int N_points = X.n_cols;
  mat K = zeros(N_points, N_points);
  
  double tmp;
  double sigma = 2;
  
  for (uword i = 0; i < N_points ;  ++i)
  {
    for (uword j = i; j < N_points ;  ++j)
    {
      /*
      tmp =  norm(X.col(i) - X.col(j),2);
      double num =  pow(tmp,2);
      double den = 2*pow(sigma,2);
      K(i,j) = exp(-num/den);
      */
      K(i,j) = pow( dot( X.col(i) , X.col(j) ) + 1, 2);
      //K(i,j) =pow( X.col(i).t()*X.col(j), 2);
      
    }
  }
  
  mat  K2 = pow( X.t()*X, 2); // Polynomial d =2.

  //K.print("K: ");
  K2.save("K2_nov26.dat", raw_ascii);
  K = symmatu(K);
  
  
  k_kmeans kkm(K2,2);
  kkm.calc(100);
  
  return 0;
}



/*
 cmake_minimum_required(VERSION 2.8)
project( grassmann_clustering)
find_package( OpenCV REQUIRED)
find_package( Armadillo REQUIRED)
add_executable( toy.exe toy_data.cpp )
target_link_libraries( toy.exe ${OpenCV_LIBS} -O1 -larmadillo)
*/